﻿cmake_minimum_required(VERSION 3.14)

project(Test0 LANGUAGES CXX)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)


set(CAFFE2_USE_CUDNN ON)
#set(CMAKE_CUDA_ARCHITECTURES 64)
#set(CMAKE_CUDA_COMPILER C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.8/bin/nvcc.exe)


find_package(OpenCV REQUIRED)

if (DEBUG)
    set(Torch_DIR "F:/Project/DeepLearning/YOLOv8/PyTorch/debug/libtorch/share/cmake/Torch")
else ()
    set(Torch_DIR "F:/Project/DeepLearning/YOLOv8/PyTorch/release/libtorch/share/cmake/Torch")
endif ()

find_package(Torch REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}")

file(GLOB SourceFiles ${SourceFileTypes})

add_executable(${PROJECT_NAME}
        ${SourceFiles}
)


INSTALL(TARGETS ${PROJECT_NAME}
        RUNTIME DESTINATION bin
        ARCHIVE DESTINATION lib
)

target_link_libraries(${PROJECT_NAME}
        PRIVATE
        ${OpenCV_LIBS}
        ${TORCH_LIBRARIES}
)

#set_target_properties(${PROJECT_NAME} PROPERTIES
#        CUDA_SEPARABLE_COMPILATION ON)

# 将dll文件复制到目标目录
#if (MSVC)
#    file(GLOB TORCH_DLLS "${TORCH_INSTALL_PREFIX}/lib/*.dll")
#    add_custom_command(TARGET ${PROJECT_NAME}
#            POST_BUILD
#            COMMAND ${CMAKE_COMMAND} -E copy_if_different
#            ${TORCH_DLLS}
#            $<TARGET_FILE_DIR:${PROJECT_NAME}>)
#endif (MSVC)
